/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package	dao;

import Hibernate.HibernateUtil;
import pojo.Log;
import pojo.Status;
import pojo.Thongso;
import pojo.Website;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class StatusDAO extends AbstractDAO {

	@Override
	protected Class getPOJOClass() {
		// TODO Auto-generated method stub
		return Status.class;
	}
	
    public Status getStatusByID(int i){
        Status log = null;
        Session session = HibernateUtil.getSessionFactory().openSession();
        try{
            log = (Status)session.get(Status.class, i);
        }
        catch(HibernateException ex){
            
        }
        finally{
            session.close();
        }
        return log;
    }
	public  boolean capnhatTrangThai(String id,
			String trangthai) 
	{
		// TODO Auto-generated method stub
		boolean flag= false;
		Session session = HibernateUtil.getSessionFactory().openSession();
		int idtt= Integer.parseInt(id);
		StatusDAO dao= new StatusDAO();
		Status  st= dao.getStatusByID(idtt);
		st.setStatus(trangthai);
		Transaction transaction = null;
		try {
			transaction = session.beginTransaction();
			session.saveOrUpdate(st);
			transaction.commit();
			flag= true;
		} catch (Exception e) {
			transaction.rollback();
		}
		finally{
		session.close();
		}		
		
		
		
		return flag;
	}
   
    
}
